<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  
  <title>第 3 页 | Wentao&#39;s Blog</title>

  
  <meta name="author" content="wentao">
  

  

  

  <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  

  <meta property="og:site_name" content="Wentao&#39;s Blog"/>

  
  <meta property="og:image" content="/favicon.ico"/>
  

  <link href="/favicon.ico" rel="icon">
  <link rel="alternate" href="/atom.xml" title="Wentao&#39;s Blog" type="application/atom+xml">
  <link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">
</head>


<body>
<div class="blog">
  <div class="content">

    <header>
  <div class="site-branding">
    <h1 class="site-title">
      <a href="/">Wentao&#39;s Blog</a>
    </h1>
    <p class="site-description"></p>
  </div>
  <nav class="site-navigation">
    <ul>
      
        <li><a href="/">主页</a></li>
      
        <li><a href="/archives">归档</a></li>
      
    </ul>
  </nav>
</header>

    <main class="site-main posts-loop">
    
  <article>

  
    
    <h3 class="article-title"><a href="/2013/11/20/Nodejs-1/"><span>Node.js初探</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/2013/11/20/Nodejs-1/" rel="bookmark">
        <time class="entry-date published" datetime="2013-11-20T10:50:05.000Z">
          2013-11-20
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h3>吐槽</h3>
<p>最近在搞公司的一个小项目.抱着<code>挖大坑</code>的想法,使用了<code>Node.js</code>和<code>redis</code>.其中的<code>redis</code>是自己一直想使用的.负责的有一个数据接口,累死累活的想尽了各种办法去优化代码,如果能够使用类似<code>redis</code>这样的<code>NOSQL</code>会轻松好多.可惜,<code>安全第一</code>.</p>
<h3>Node.js</h3>
<p>Node.js配置环境什么的还是挺简单的.由于微软的原因,Node.js对Windows有了很好的支持.</p>
<h4>安装nodejs</h4>
<p>安装<code>nodejs</code>的话,可以通过官网提供的 msi安装包来安装,但是这样安装的话,不能很好的控制不同的版本.所以最好的办法还是自己来控制了.
下载已经编译好的<code>nodejs</code>版本.</p>
<p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">http://nodejs.org/dist/</div></pre></td></tr></table></figure></p>
<p>如下的操作创建好目录关系</p>
<p><figure class="highlight bat"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> D:\soft</div><div class="line"><span class="built_in">mkdir</span> nodejs</div><div class="line"><span class="built_in">cd</span> nodejs</div><div class="line"><span class="built_in">mkdir</span> node</div><div class="line"><span class="built_in">mkdir</span> npm-global</div><div class="line"><span class="built_in">mkdir</span> npm-cache</div></pre></td></tr></table></figure></p>
<p>然后将下载到的nodejs的压缩包解压到node目录中</p>
<h4>安装npm</h4>
<p>从<code>http://nodejs.org/dist/npm/</code> 这下载需要的npm地址.
然后解压到node目录.</p>
<h4>设置环境变量</h4>
<p>在系统的path里面加入nodejs的目录.</p>
<p>可以通过<code>echo %path%</code>来检查设定是否正确.</p>
<h4>比较好玩的modules</h4>
<h5>Express</h5>
<p><a href="http://expressjs.com/" target="_blank" rel="external">Express</a>.算是目前最主流的一个Node.js平台下面的web框架了.有各种页面模版可以支持.学习和使用的成本都是很低的.</p>
<h5>log4js</h5>
<p><a href="http://log4js.berlios.de/index.html" target="_blank" rel="external">log4js</a>log4X的一个变种了.基本上使用和配置都和log4X的其它系列差不多.挺顺手的.不过尽量在万不得已的情况下在写日志.Node.js这种非阻塞的东东,在写日志方面的确没有什么太大的优势.</p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/categories/Dev/">Dev</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/tags/技术-Node-js/">技术,Node.js</a>
    </span>
    

    </div>

    
    <div class="article-meta pull-right">
      <span>
        <i class="icon-comments"></i>
        <span>
          <a href="http://wentao.org/2013/11/20/Nodejs-1/#comment">评论</a>
        </span>
      </span>
    </div>
    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/2013/09/02/10-years/"><span>十年</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/2013/09/02/10-years/" rel="bookmark">
        <time class="entry-date published" datetime="2013-09-02T11:47:13.000Z">
          2013-09-02
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        
      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/categories/Life/">Life</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/tags/think/">think</a>
    </span>
    

    </div>

    
    <div class="article-meta pull-right">
      <span>
        <i class="icon-comments"></i>
        <span>
          <a href="http://wentao.org/2013/09/02/10-years/#comment">评论</a>
        </span>
      </span>
    </div>
    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/2013/07/20/build-a-habit/"><span>习惯的养成</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/2013/07/20/build-a-habit/" rel="bookmark">
        <time class="entry-date published" datetime="2013-07-20T00:30:13.000Z">
          2013-07-20
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <p>清明前两天的时候，因为早点到公司开会。所以起床就早了一些，6:00起床，然后6:30出门了。坐公交车到公司，人很少，速度很快。一个小时不到就到了公司。。。当时忽然就冒出来这么一个想法，如果每天都这样的时间起床，那么早上乘坐公交车的体验就会有很大的提升。而且早点到公司可以对自己一天的工作有一个计划和安排。（这个是后来由于一些事情导致的。）</p>
<p>然后就这么坚持到了现在，可以说出了请假的时候不去公司，每天都是这样。最开始的时候还需要闹钟之类的，后来发现根本不用闹钟了，已成成了生物钟。到了那个时间点就自动起来了。每天乘坐公交的时间也大大的缩小了，时不时的还可以混个位置坐，看一路的小说或者睡上一路。</p>
<p>习惯的养成需要多久呢？不用管这个，一步一步的来就好了。设定一个不太难实现的目标，然后一步步的加码。也许最后会过来看的时候就会让自己惊讶的。老外貌似还挺爱研究这个的。记得看过一个说法是坚持15天的话，就会成为习惯。也有说法是<a href="http://www.guokr.com/article/380606/" target="_blank" rel="external">21天</a>。不过，感觉习惯培养很难，但是如果要毁掉的话，还是挺快的。所以坚持比较重要，一直到成为骨子里面的东西。</p>
<p>目前在做得事情就是每天总结自己的工作和生活，记日志，写工作总结之类的。</p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/categories/Life/">Life</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/tags/habit-hiit/">habit,hiit</a>
    </span>
    

    </div>

    
    <div class="article-meta pull-right">
      <span>
        <i class="icon-comments"></i>
        <span>
          <a href="http://wentao.org/2013/07/20/build-a-habit/#comment">评论</a>
        </span>
      </span>
    </div>
    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/2013/04/20/Auto-Change-Font-Size/"><span>字体大小自动随宽度和内容改变</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/2013/04/20/Auto-Change-Font-Size/" rel="bookmark">
        <time class="entry-date published" datetime="2013-04-20T07:30:13.000Z">
          2013-04-20
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <p>字体的大小设定可以在开始的时候指定.但是有时候需要根据窗口或者文字的长短来指定.那么这个时候就需要用到时间Paint了.
继承与Control的控件都有这个事件.也可以override OnPaint函数.
主要考虑两个因素,宽度和高度.比方如果字体的长度小于一个比例,则增加字体大小.如果大于一个比例则减小字体.</p>
<p>高度也是同样的道理.控制在一个比例范围以内就可以了.</p>
<p><figure class="highlight csharp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div></pre></td><td class="code"><pre><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> 标题重绘时候的处理</span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="sender"&gt;</span><span class="doctag">&lt;/param&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="e"&gt;</span><span class="doctag">&lt;/param&gt;</span></span></div><div class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">txtTitle_Paint</span>(<span class="params"><span class="keyword">object</span> sender, PaintEventArgs e</span>)</span></div><div class="line">&#123;</div><div class="line">    <span class="keyword">var</span> lbl = sender <span class="keyword">as</span> Label;</div><div class="line">    <span class="keyword">if</span> (lbl == <span class="literal">null</span>)</div><div class="line">    &#123;</div><div class="line">        <span class="keyword">return</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">var</span> size = MeasureStringWidth(lbl.Text, e.Graphics, lbl.Font);</div><div class="line">    <span class="keyword">float</span> diff = size.Width / lbl.Width;</div><div class="line">    <span class="keyword">var</span> font = lbl.Font;</div><div class="line">    <span class="keyword">while</span> ((diff &gt; <span class="number">0.6</span> || diff &lt; <span class="number">0.4</span>))</div><div class="line">    &#123;</div><div class="line"></div><div class="line">        font = <span class="keyword">new</span> Font(font.Name, diff &gt; <span class="number">0.5</span> ? font.Size - <span class="number">1</span> : font.Size + <span class="number">1</span>, font.Style);</div><div class="line">        size = MeasureStringWidth(lbl.Text, e.Graphics, font);</div><div class="line">        <span class="keyword">if</span> (size.Height &gt; lbl.Height)</div><div class="line">        &#123;</div><div class="line">            font = <span class="keyword">new</span> Font(font.Name, diff &gt; <span class="number">0.5</span> ? font.Size + <span class="number">1</span> : font.Size - <span class="number">1</span>, lbl.Font.Style);</div><div class="line">            <span class="keyword">break</span>;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">if</span> (font.Size &lt; <span class="number">5</span>)</div><div class="line">        &#123;</div><div class="line">            <span class="keyword">break</span>;</div><div class="line">        &#125;</div><div class="line">        diff = size.Width / lbl.Width;</div><div class="line">    &#125;</div><div class="line">    lbl.Font = font;</div><div class="line">&#125;</div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> 获得文字的高宽</span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="text"&gt;</span>文字内容<span class="doctag">&lt;/param&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="graphic"&gt;</span>绘画<span class="doctag">&lt;/param&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="font"&gt;</span>字体<span class="doctag">&lt;/param&gt;</span></span></div><div class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;returns&gt;</span>大小<span class="doctag">&lt;/returns&gt;</span></span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> SizeF <span class="title">MeasureStringWidth</span>(<span class="params"><span class="keyword">string</span> text, Graphics graphic, Font font</span>)</span></div><div class="line">&#123;</div><div class="line">    SizeF tmpSize = System.Windows.Forms.TextRenderer.MeasureText(text, font);</div><div class="line">    <span class="keyword">return</span> tmpSize;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/categories/Dev/">Dev</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/tags/Net/">.Net</a>
    </span>
    

    </div>

    
    <div class="article-meta pull-right">
      <span>
        <i class="icon-comments"></i>
        <span>
          <a href="http://wentao.org/2013/04/20/Auto-Change-Font-Size/#comment">评论</a>
        </span>
      </span>
    </div>
    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/2013/04/18/2013-4-18-Change-Assembly-Version/"><span>AutoIt修改Assembly的版本号</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/2013/04/18/2013-4-18-Change-Assembly-Version/" rel="bookmark">
        <time class="entry-date published" datetime="2013-04-18T08:26:25.000Z">
          2013-04-18
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <p>部门搞了自动构建.以前自己也用过<code>ccnet</code>之类的工具.有很多的版本号递增的规则很是方便.可惜我们不是用类似的工具,所以版本号这块就只能自己手动来修改了.不过这个修改也挺麻烦的.后来就考虑写一个小工具来完成版本号的修改.本来打算用<code>C#</code>做一个.但是还依赖<code>.Net Framework</code>.刚好最近看了一下<code>AutoIt</code>,就用这个练习了一下.于是就做出了这么一个东东.</p>
<p><figure class="highlight autoit"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">NoTrayIcon</span></span></div><div class="line"><span class="meta">#region <span class="comment">;**** Directives created by AutoIt3Wrapper_GUI ****</span></span></div><div class="line"><span class="meta">#AutoIt3Wrapper_Icon=ti.ico</span></div><div class="line"><span class="meta">#AutoIt3Wrapper_Run_Tidy=y</span></div><div class="line"><span class="meta">#endregion <span class="comment">;**** Directives created by AutoIt3Wrapper_GUI ****</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;File.au3&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;Array.au3&gt;</span></span></div><div class="line"></div><div class="line"><span class="keyword">Local</span> $path = <span class="string">'D:\code\batchAgent'</span></div><div class="line"><span class="keyword">Local</span> $aVersion = <span class="string">'1.0.0.3'</span></div><div class="line"><span class="keyword">Local</span> $aRecords</div><div class="line"><span class="keyword">If</span> $CmdLine[0] &gt;= <span class="number">2</span> <span class="keyword">Then</span></div><div class="line">	$path = $CmdLine[1]</div><div class="line">	$aVersion = $CmdLine[2]</div><div class="line"><span class="keyword">Else</span></div><div class="line">	<span class="built_in">MsgBox</span>(<span class="number">0</span>, <span class="string">"Warn"</span>, <span class="string">'测试模式'</span>)</div><div class="line"><span class="keyword">EndIf</span></div><div class="line"><span class="keyword">Local</span> $var = <span class="built_in">StringRight</span>($path, <span class="number">1</span>)</div><div class="line"></div><div class="line"><span class="keyword">If</span> <span class="built_in">StringCompare</span>($var, <span class="string">'\'</span>) &lt;&gt; <span class="number">0</span> <span class="keyword">Then</span></div><div class="line">	$path = $path &amp; <span class="string">'\'</span></div><div class="line"><span class="keyword">EndIf</span></div><div class="line"></div><div class="line"><span class="keyword">Local</span> $FileList = _FileListToArray($path, <span class="string">'*'</span>, <span class="number">2</span>)</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">For</span> $i = <span class="number">1</span> <span class="keyword">To</span> $FileList[0]</div><div class="line"></div><div class="line">	<span class="keyword">If</span> _FileReadToArray($path &amp; $FileList[$i] &amp; <span class="string">'\Properties\AssemblyInfo.cs'</span>, $aRecords) <span class="keyword">Then</span></div><div class="line">		<span class="comment">;_ArrayDisplay($aRecords, "$aRecords")</span></div><div class="line">		<span class="keyword">For</span> $y = <span class="number">1</span> <span class="keyword">To</span> $aRecords[0]</div><div class="line">			<span class="keyword">Local</span> $result = <span class="built_in">StringRegExp</span>($aRecords[$y], <span class="string">"^\[assembly\:\s\w*Version"</span>)</div><div class="line"></div><div class="line">			<span class="keyword">If</span> $result &gt; <span class="number">0</span> <span class="keyword">Then</span></div><div class="line">				<span class="comment">;用正则替换</span></div><div class="line">				<span class="keyword">Local</span> $sOutput = <span class="built_in">StringRegExpReplace</span>($aRecords[$y], <span class="string">'\"([\d&#123;1,&#125;?\.]*)\"'</span>, <span class="string">'"'</span> &amp; $aVersion &amp; <span class="string">'"'</span>)</div><div class="line">				$aRecords[$y] = $sOutput</div><div class="line"></div><div class="line">			<span class="keyword">EndIf</span></div><div class="line">		<span class="keyword">Next</span></div><div class="line">		<span class="keyword">Local</span> $hFile = <span class="built_in">FileOpen</span>($path &amp; $FileList[$i] &amp; <span class="string">'\Properties\AssemblyInfo.cs'</span>, <span class="number">2</span> + <span class="number">128</span>) <span class="comment">; 1 = append</span></div><div class="line">		<span class="keyword">For</span> $y = <span class="number">1</span> <span class="keyword">To</span> $aRecords[0]</div><div class="line">			<span class="keyword">Local</span> $hFileWrite = <span class="built_in">FileWrite</span>($hFile, $aRecords[$y] &amp; <span class="symbol">@CRLF</span>)</div><div class="line">		<span class="keyword">Next</span></div><div class="line">		<span class="built_in">FileClose</span>($hFile)</div><div class="line">	<span class="keyword">EndIf</span></div><div class="line"><span class="keyword">Next</span></div></pre></td></tr></table></figure></p>
<p>用上面的脚本编译一个exe,然后传递一个项目的路径和版本号就可以把Assembly的版本号改掉了.</p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/categories/Dev/">Dev</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/tags/Net-AutoIt/">.Net,AutoIt</a>
    </span>
    

    </div>

    
    <div class="article-meta pull-right">
      <span>
        <i class="icon-comments"></i>
        <span>
          <a href="http://wentao.org/2013/04/18/2013-4-18-Change-Assembly-Version/#comment">评论</a>
        </span>
      </span>
    </div>
    
  </div>
</article>




<nav class="pagination">
  
  <a href="/page/2/" class="pagination-prev">上一页</a>
  
  
  <a href="/page/4/" class="pagination-next">下一页</a>
  
</nav>
    </main>

    <footer class="site-footer">
  <p class="site-info">
    Proudly powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and
    Theme by <a href="https://github.com/CodeDaraW/Hacker" target="_blank">Hacker</a>
    </br>
    
    &copy; 2016 wentao
    
  </p>
</footer>
    
  </div>
</div>
</body>
</html>